﻿using Dapper;
using Model.ViewModels;
using Respository;
using Respository.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;

namespace GBLServices
{
    public class MenuServices
    {
        public IRepositoryBase _dal;
        public MenuServices(IRepositoryBase dal)
        {
            _dal = dal;
        }

        public virtual async Task<List<MenuViewModel>> GetMenuAsync(int Id)
        {
            var sqlParameters = new DynamicParameters();
            sqlParameters.Add("@userid", Id);
            return await _dal.QuerySPListAsync<MenuViewModel>("[user_getmainmenu_new]", sqlParameters);
            
        }
        public virtual async Task<DataSet> GetMenuDataSetAsync(int Id)
        {
            //SqlParameter[] sqlParameters = new SqlParameter[1];
            //sqlParameters[0] = new SqlParameter("@userid", Id);
            //sqlParameters[0].Direction = System.Data.ParameterDirection.Input;

            var sqlParameters = new DynamicParameters();
            sqlParameters.Add("@userid", Id);
            return await _dal.QueryDataSet("[user_getmainmenu_new]", sqlParameters, System.Data.CommandType.StoredProcedure);
        }
        public virtual List<MenuViewModel> GetMenu(int Id)
        {
            var sqlParameters = new DynamicParameters();
            sqlParameters.Add("@userid", Id);
            return _dal.QuerySPList<MenuViewModel>("[user_getmainmenu_new]", sqlParameters);
        }
    }
}
